package com.leoblog.test.util;

import com.leoblog.test.base.AbstractUTestBaseTestCase;
import com.leoblog.util.GenericUtil;
@SuppressWarnings("unchecked")
public class UTestGenericUtil extends AbstractUTestBaseTestCase {
	
	class GenericClass<T>
	{
		
	}	
	
	class GenericParamClass extends GenericClass<String>
	{
		
	}
	
	class GenericNoParamClass extends GenericClass
	{
		
	}
	
	public void testGeneric()
	{
		GenericParamClass entity = new GenericParamClass();
		Class entityClass = GenericUtil.getSuperClassGenricType(entity.getClass(), 0);
		assertEquals(String.class, entityClass);
	}
	
	public void testNoGeneric()
	{
		String entity = new String();
		Class entityClass = GenericUtil.getSuperClassGenricType(entity.getClass(), 0);
		assertEquals(Object.class, entityClass);
	}
	
	public void testGenericOutOfIndex()
	{
		GenericParamClass entity = new GenericParamClass();
		Class entityClass = GenericUtil.getSuperClassGenricType(entity.getClass(), 1);
		assertEquals(Object.class, entityClass);
	}
	
	public void testGenericNoParam()
	{
		GenericNoParamClass entity = new GenericNoParamClass();
		Class entityClass = GenericUtil.getSuperClassGenricType(entity.getClass(), 0);
		assertEquals(Object.class, entityClass);
	}
}
